<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="http状态碼 2xx表示成功   200：OK 表示服务器正常处理 206：表示客户端进行了范围请求，服务返回行了范围请求   3xx重定向   301：永久重定向，表示uri已经分配了新的地址，以后使用这个uri访问资源 302：临时重定向，表示只是暂时的分配了新的地址，本次请求使用新的地址 303：临时重定向，和302区别时要求客户端使用get方法进行请求 304:为满足条件，表示服务器可以">
<meta property="og:type" content="article">
<meta property="og:title" content="kyssion-blog">
<meta property="og:url" content="http://yoursite.com/2018/10/09/详解http协议-状态码和报文信息/index.html">
<meta property="og:site_name" content="kyssion-blog">
<meta property="og:description" content="http状态碼 2xx表示成功   200：OK 表示服务器正常处理 206：表示客户端进行了范围请求，服务返回行了范围请求   3xx重定向   301：永久重定向，表示uri已经分配了新的地址，以后使用这个uri访问资源 302：临时重定向，表示只是暂时的分配了新的地址，本次请求使用新的地址 303：临时重定向，和302区别时要求客户端使用get方法进行请求 304:为满足条件，表示服务器可以">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/1.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/2.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/3.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/4.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/5.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/6.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/7.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/8.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/9.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/10.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/11.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/12.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/13.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/14.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/15.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/16.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/17.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/18.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/19.png">
<meta property="og:image" content="http://yoursite.com/blogimg/http2/20.png">
<meta property="og:updated_time" content="2018-10-09T07:22:37.341Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="kyssion-blog">
<meta name="twitter:description" content="http状态碼 2xx表示成功   200：OK 表示服务器正常处理 206：表示客户端进行了范围请求，服务返回行了范围请求   3xx重定向   301：永久重定向，表示uri已经分配了新的地址，以后使用这个uri访问资源 302：临时重定向，表示只是暂时的分配了新的地址，本次请求使用新的地址 303：临时重定向，和302区别时要求客户端使用get方法进行请求 304:为满足条件，表示服务器可以">
<meta name="twitter:image" content="http://yoursite.com/blogimg/http2/1.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/10/09/详解http协议-状态码和报文信息/"/>





  <title> | kyssion-blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">kyssion-blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-schedule">
          <a href="/schedule/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-calendar"></i> <br />
            
            日程表
          </a>
        </li>
      
        
        <li class="menu-item menu-item-sitemap">
          <a href="/sitemap.xml" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-sitemap"></i> <br />
            
            站点地图
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/10/09/详解http协议-状态码和报文信息/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kyssion">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="kyssion-blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline"></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-10-09T15:22:37+08:00">
                2018-10-09
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="http状态碼"><a href="#http状态碼" class="headerlink" title="http状态碼"></a>http状态碼</h3><blockquote>
<p>2xx表示成功</p>
</blockquote>
<ul>
<li>200：OK 表示服务器正常处理</li>
<li>206：表示客户端进行了范围请求，服务返回行了范围请求</li>
</ul>
<blockquote>
<p>3xx重定向</p>
</blockquote>
<ul>
<li>301：永久重定向，表示uri已经分配了新的地址，以后使用这个uri访问资源</li>
<li>302：临时重定向，表示只是暂时的分配了新的地址，本次请求使用新的地址</li>
<li>303：临时重定向，和302区别时要求客户端使用get方法进行请求</li>
<li>304:为满足条件，表示服务器可以进行请求，但是没有满足head中的（if-×）类型字段的条件</li>
</ul>
<blockquote>
<p>4xx表示客户端错误</p>
</blockquote>
<ul>
<li>400：语法错误</li>
<li>401：需要进行验证</li>
<li>403：访问被拒绝</li>
<li>404：服务器上无法找到被请求的资源</li>
</ul>
<blockquote>
<p>5xx服务器错误</p>
</blockquote>
<ul>
<li>500：服务器故障</li>
<li>503：服务器超负荷，或停机维护，服务器返回Retry-after表示需要的时间</li>
</ul>
<h3 id="http协议首部字段的书写格式"><a href="#http协议首部字段的书写格式" class="headerlink" title="http协议首部字段的书写格式"></a>http协议首部字段的书写格式</h3><p><img src="/blogimg/http2/1.png" alt=""></p>
<h3 id="http协议通用首部字段"><a href="#http协议通用首部字段" class="headerlink" title="http协议通用首部字段"></a>http协议通用首部字段</h3><p><img src="/blogimg/http2/2.png" alt=""></p>
<h4 id="cache-Control"><a href="#cache-Control" class="headerlink" title="cache-Control"></a>cache-Control</h4><p><strong>格式</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Cache-Control: <span class="keyword">private</span>,max-age=<span class="number">0</span>,no-cache</span><br></pre></td></tr></table></figure>
<p><strong>作用：</strong>操作缓存机制</p>
<blockquote>
<p>缓存请求指令</p>
</blockquote>
<p><img src="/blogimg/http2/3.png" alt=""></p>
<p><img src="/blogimg/http2/4.png" alt=""></p>
<blockquote>
<p>缓存响应指令</p>
</blockquote>
<p><img src="/blogimg/http2/5.png" alt=""></p>
<h4 id="connection"><a href="#connection" class="headerlink" title="connection"></a>connection</h4><p>控制代理表明相关的字段不被转发 和管理持久链接</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Connection:不被转发的字段名称</span><br></pre></td></tr></table></figure>
<blockquote>
<p>关闭持久链接</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">connection:close</span><br></pre></td></tr></table></figure>
<blockquote>
<p>开启持久链接</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">connection:keep-alive</span><br></pre></td></tr></table></figure>
<h4 id="data"><a href="#data" class="headerlink" title="data"></a>data</h4><blockquote>
<p>创建时间的报文</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Date:Sun, <span class="number">08</span> Oct <span class="number">2017</span> <span class="number">11</span>:<span class="number">30</span>:<span class="number">41</span> GMT</span><br></pre></td></tr></table></figure>
<blockquote>
<p>Trailer</p>
</blockquote>
<p>首部字段Trailer会事先说明报文主体后记录了那些首部字段。该首部字段可应用在HTTP/1.1版本分块传输编码时。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">Transfer-Encoding:chunk</span><br><span class="line">Trailer:Expires</span><br><span class="line"> </span><br><span class="line">cf0   &lt;---<span class="number">16</span>进制 <span class="number">10</span>进制<span class="number">3312</span></span><br><span class="line">-----<span class="number">3312</span>-字节-----</span><br><span class="line"><span class="number">0</span> &lt;----表示结束</span><br><span class="line">Expires：Thu，<span class="number">15</span> Apr  <span class="number">2010</span>  <span class="number">20</span>：<span class="number">00</span>：<span class="number">00</span>  GMT;</span><br></pre></td></tr></table></figure>
<h4 id="Transfer-Encoding-chunk"><a href="#Transfer-Encoding-chunk" class="headerlink" title="Transfer-Encoding:chunk"></a>Transfer-Encoding:chunk</h4><blockquote>
<p>http1.1中表示分块请求</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">Transfer-Encoding:chunk</span><br><span class="line">Trailer:Expires</span><br><span class="line">cf0   &lt;---<span class="number">16</span>进制 <span class="number">10</span>进制<span class="number">3312</span></span><br><span class="line">-----<span class="number">3312</span>-字节-----</span><br><span class="line"><span class="number">392</span></span><br><span class="line">----<span class="number">914</span>字节-----</span><br><span class="line"><span class="number">0</span> &lt;----表示结束</span><br><span class="line">Expires：Thu，<span class="number">15</span> Apr  <span class="number">2010</span>  <span class="number">20</span>：<span class="number">00</span>：<span class="number">00</span>  GMT;</span><br></pre></td></tr></table></figure>
<h4 id="upgrade"><a href="#upgrade" class="headerlink" title="upgrade"></a>upgrade</h4><p>表明是否支持更加高级的协议</p>
<p><img src="/blogimg/http2/6.png" alt=""></p>
<h4 id="via"><a href="#via" class="headerlink" title="via"></a>via</h4><blockquote>
<p>一般和trace连用用来追踪服务器信息</p>
</blockquote>
<p><img src="/blogimg/http2/7.png" alt=""></p>
<h3 id="http协议请求首部字段"><a href="#http协议请求首部字段" class="headerlink" title="http协议请求首部字段"></a>http协议请求首部字段</h3><p><img src="/blogimg/http2/8.png" alt=""></p>
<h4 id="Accept等"><a href="#Accept等" class="headerlink" title="Accept等"></a>Accept等</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Accept:image/webp,image/apng,image<span class="comment">/*,*/</span>*;q=<span class="number">0.8</span></span><br><span class="line">Accept-Encoding:gzip, deflate, br</span><br><span class="line">Accept-Language:zh-CN,zh;q=<span class="number">0.8</span></span><br><span class="line">Accept-Charset:UTF-<span class="number">8</span>;q=<span class="number">0.8</span>,iso-<span class="number">8859</span>-<span class="number">5</span></span><br></pre></td></tr></table></figure>
<h4 id="authorization和proxy-authrization"><a href="#authorization和proxy-authrization" class="headerlink" title="authorization和proxy-authrization"></a>authorization和proxy-authrization</h4><p>认证相关：401等</p>
<h4 id="form"><a href="#form" class="headerlink" title="form"></a>form</h4><p>使用代理的时候告诉电子邮箱的地址</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">form: <span class="number">1409915687</span><span class="meta">@qq</span>.com</span><br></pre></td></tr></table></figure>
<h4 id="if-xxx"><a href="#if-xxx" class="headerlink" title="if-xxx"></a>if-xxx</h4><p>if-match：比对match参数和文件的ETag值 相同返回200 否则412</p>
<p><img src="/blogimg/http2/9.png" alt=""></p>
<p>if-Modified-Since:表示返回文件的最后更新底线，如果文件的实际更新时间在字段时间之前则失败反之成功  （if-unmodifed-since 和这个作用相反）<br><img src="/blogimg/http2/10.png" alt=""><br>if-no-match:和if-mathch 作用相反，不匹配的时候返回成功<br><img src="/blogimg/http2/11.png" alt=""><br>if-Range：如果该字段的ETag值或者时间相同就允许做范围资源请求<br><img src="/blogimg/http2/12.png" alt=""></p>
<h4 id="Max-forwards"><a href="#Max-forwards" class="headerlink" title="Max-forwards"></a>Max-forwards</h4><p>指定转发的次数</p>
<p><img src="/blogimg/http2/13.png" alt=""></p>
<h4 id="Range"><a href="#Range" class="headerlink" title="Range"></a>Range</h4><p>范围返回</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Range：bytes：<span class="number">100</span>-<span class="number">2000</span></span><br></pre></td></tr></table></figure>
<h4 id="TE"><a href="#TE" class="headerlink" title="TE"></a>TE</h4><p>指定传输编码的方式– 可以使用trailers指定的相关字段</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">TE:trailers</span><br></pre></td></tr></table></figure>
<h4 id="User-Agent"><a href="#User-Agent" class="headerlink" title="User-Agent"></a>User-Agent</h4><p>用户的浏览器相关的信息</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">User-Agent:Mozilla/<span class="number">5.0</span> (X11; Linux x86_64) AppleWebKit/<span class="number">537.36</span> (KHTML, like Gecko) Chrome/<span class="number">61.0</span>.3163.100 Safari/<span class="number">537.36</span></span><br></pre></td></tr></table></figure>
<h3 id="http协议响应首部字段"><a href="#http协议响应首部字段" class="headerlink" title="http协议响应首部字段"></a>http协议响应首部字段</h3><p><img src="/blogimg/http2/14.png" alt=""></p>
<p><img src="/blogimg/http2/15.png" alt=""></p>
<h4 id="ETag"><a href="#ETag" class="headerlink" title="ETag"></a>ETag</h4><p>资源的唯一标识符，当使用不同的语言环境的时候可能会出现相同的uri地址但是指向的却是不同的资源，这就使用ETag进一步标识所要使用的资源</p>
<p><img src="/blogimg/http2/16.png" alt=""></p>
<h4 id="location"><a href="#location" class="headerlink" title="location"></a>location</h4><p>配合3xx 表示重定向的地址</p>
<h4 id="Retry-after"><a href="#Retry-after" class="headerlink" title="Retry-after"></a>Retry-after</h4><p>指定多久呵在进行相应，配合503</p>
<h4 id="server"><a href="#server" class="headerlink" title="server"></a>server</h4><p>表示服务器信息</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">server：nginx/<span class="number">1.12</span>.0</span><br></pre></td></tr></table></figure>
<h4 id="Vary"><a href="#Vary" class="headerlink" title="Vary"></a>Vary</h4><p><img src="/blogimg/http2/17.png" alt=""></p>
<h3 id="http协议实体首部字段"><a href="#http协议实体首部字段" class="headerlink" title="http协议实体首部字段"></a>http协议实体首部字段</h3><p><img src="/blogimg/http2/18.png" alt=""></p>
<h4 id="allow"><a href="#allow" class="headerlink" title="allow"></a>allow</h4><p>指定服务器指定的uri请求方法GET等</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Allow：GET,POST</span><br></pre></td></tr></table></figure>
<h4 id="Content"><a href="#Content" class="headerlink" title="Content-*"></a>Content-*</h4><p>实体部分的编码</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">Content-Encode：gzip</span><br><span class="line">Content-Language：zh-CN</span><br><span class="line">Content-Length:<span class="number">15000</span></span><br><span class="line">Content-Location:www.hi-kys.me</span><br><span class="line">Content-MD5:UEUEJDJNWIQSNNFIFNEF=</span><br><span class="line">Content-Range:bytes:<span class="number">500</span>-<span class="number">1000</span>/<span class="number">1000</span></span><br><span class="line">Content-Type:text/html;charset=UTF-<span class="number">8</span></span><br></pre></td></tr></table></figure>
<h4 id="Expires"><a href="#Expires" class="headerlink" title="Expires"></a>Expires</h4><p>指定资源失效的日期，优先级小于Cache-Control：max-age</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Expires：Thu，<span class="number">15</span> Apr <span class="number">2010</span> <span class="number">20</span>：<span class="number">00</span>：<span class="number">00</span> GMT;</span><br></pre></td></tr></table></figure>
<h4 id="last-Modified"><a href="#last-Modified" class="headerlink" title="last-Modified"></a>last-Modified</h4><p>返回文件最终修改日期</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Last-Modified：Thu，<span class="number">15</span> Apr  <span class="number">2010</span>  <span class="number">20</span>：<span class="number">00</span>：<span class="number">00</span>  GMT</span><br></pre></td></tr></table></figure>
<h3 id="其他非http-1-1首部"><a href="#其他非http-1-1首部" class="headerlink" title="其他非http/1.1首部"></a>其他非http/1.1首部</h3><h4 id="cookie和setcookie"><a href="#cookie和setcookie" class="headerlink" title="cookie和setcookie"></a>cookie和setcookie</h4><p>cookie相应格式</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Set-Cookie:sid=<span class="number">123</span>[;name=value....];status=enable;expires=Thu <span class="string">' 15 Apr 2019 20:00:00  GMT;path=/;domain=.hackr.com</span></span><br></pre></td></tr></table></figure>
<p>相关字段属性</p>
<p><img src="/blogimg/http2/19.png" alt=""></p>
<p><img src="/blogimg/http2/20.png" alt=""></p>
<ul>
<li>Domain：域，表示当前cookie所属于哪个域或子域下面。</li>
<li>Path：表示cookie的所属路径。</li>
<li>Expire time/Max-age：表示了cookie的有效期。expire的值，是一个时间，过了这个时间，该cookie就失效了。或者是用max-age指定当前cookie是在多长时间之后而失效。如果服务器返回的一个cookie，没有指定其expire time，那么表明此cookie有效期只是当前的session，即是session cookie，当前session会话结束后，就过期了。对应的，当关闭（浏览器中）该页面的时候，此cookie就应该被浏览器所删除了。</li>
<li>secure：表示该cookie只能用https传输。一般用于包含认证信息的cookie，要求传输此cookie的时候，必须用https传输。</li>
<li>httponly：表示此cookie必须用于http或https传输。这意味着，浏览器脚本，比如javascript中，是不允许访问操作此cookie的。</li>
</ul>
<p>从客户端发送cookie给服务器的时候，是不发送cookie的各个属性的，而只是发送对应的名称和值。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Cookie：sid=<span class="number">123</span>[;name=value....]</span><br></pre></td></tr></table></figure>
<h3 id="http首部基于缓存代理和非缓存代理行为的分类"><a href="#http首部基于缓存代理和非缓存代理行为的分类" class="headerlink" title="http首部基于缓存代理和非缓存代理行为的分类"></a>http首部基于缓存代理和非缓存代理行为的分类</h3><ol>
<li>端到端首部 : 转换过程中不能丢失，必须转发的首部</li>
<li>逐跳首部 : http1.1需要提供connection字段，经过一层代理之后可以不进行转发</li>
</ol>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/10/09/深入理解mybatis（二）映射文件/" rel="next" title="">
                <i class="fa fa-chevron-left"></i> 
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/10/09/算法阶段性小结(二)/" rel="prev" title="">
                 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">kyssion</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">133</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                
                  <span class="site-state-item-count">3</span>
                  <span class="site-state-item-name">分类</span>
                
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">标签</span>
                
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#http状态碼"><span class="nav-number">1.</span> <span class="nav-text">http状态碼</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#http协议首部字段的书写格式"><span class="nav-number">2.</span> <span class="nav-text">http协议首部字段的书写格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#http协议通用首部字段"><span class="nav-number">3.</span> <span class="nav-text">http协议通用首部字段</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#cache-Control"><span class="nav-number">3.1.</span> <span class="nav-text">cache-Control</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#connection"><span class="nav-number">3.2.</span> <span class="nav-text">connection</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#data"><span class="nav-number">3.3.</span> <span class="nav-text">data</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Transfer-Encoding-chunk"><span class="nav-number">3.4.</span> <span class="nav-text">Transfer-Encoding:chunk</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#upgrade"><span class="nav-number">3.5.</span> <span class="nav-text">upgrade</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#via"><span class="nav-number">3.6.</span> <span class="nav-text">via</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#http协议请求首部字段"><span class="nav-number">4.</span> <span class="nav-text">http协议请求首部字段</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Accept等"><span class="nav-number">4.1.</span> <span class="nav-text">Accept等</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#authorization和proxy-authrization"><span class="nav-number">4.2.</span> <span class="nav-text">authorization和proxy-authrization</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#form"><span class="nav-number">4.3.</span> <span class="nav-text">form</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#if-xxx"><span class="nav-number">4.4.</span> <span class="nav-text">if-xxx</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Max-forwards"><span class="nav-number">4.5.</span> <span class="nav-text">Max-forwards</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Range"><span class="nav-number">4.6.</span> <span class="nav-text">Range</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#TE"><span class="nav-number">4.7.</span> <span class="nav-text">TE</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#User-Agent"><span class="nav-number">4.8.</span> <span class="nav-text">User-Agent</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#http协议响应首部字段"><span class="nav-number">5.</span> <span class="nav-text">http协议响应首部字段</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#ETag"><span class="nav-number">5.1.</span> <span class="nav-text">ETag</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#location"><span class="nav-number">5.2.</span> <span class="nav-text">location</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Retry-after"><span class="nav-number">5.3.</span> <span class="nav-text">Retry-after</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#server"><span class="nav-number">5.4.</span> <span class="nav-text">server</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Vary"><span class="nav-number">5.5.</span> <span class="nav-text">Vary</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#http协议实体首部字段"><span class="nav-number">6.</span> <span class="nav-text">http协议实体首部字段</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#allow"><span class="nav-number">6.1.</span> <span class="nav-text">allow</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Content"><span class="nav-number">6.2.</span> <span class="nav-text">Content-*</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Expires"><span class="nav-number">6.3.</span> <span class="nav-text">Expires</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#last-Modified"><span class="nav-number">6.4.</span> <span class="nav-text">last-Modified</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#其他非http-1-1首部"><span class="nav-number">7.</span> <span class="nav-text">其他非http/1.1首部</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#cookie和setcookie"><span class="nav-number">7.1.</span> <span class="nav-text">cookie和setcookie</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#http首部基于缓存代理和非缓存代理行为的分类"><span class="nav-number">8.</span> <span class="nav-text">http首部基于缓存代理和非缓存代理行为的分类</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">kyssion</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
